package com.剑指offer.第三章;

public class 回文字符串 {

    public static boolean resolve(String s1) {
        int start = 0;
        int end = s1.length() - 1;

        while (start < end) {
            char c = s1.charAt(start);
            char b = s1.charAt(end);
            if (!Character.isLetterOrDigit(c)) {
                start++;
                /**
                 * 如果字符是字母或数字此方法返回true，否则为false。
                 */
            } else if (!Character.isLetterOrDigit(b)) {
                end--;
            } else {
                char c1 = Character.toLowerCase(c);
                char c2 = Character.toLowerCase(b);
                if (c1 != c2) {
                    return false;
                }
                start++;
                end--;
            }
        }

        return true;
    }

    public static void main(String[] args) {
        System.out.println(resolve("abac"));
    }

}
